package manage.actions;

import manage.commons.Constants;
import manage.commons.annontations.RequiredLogin;
import manage.commons.interceptors.CurrentWorkerAware;
import manage.modules.menu.service.MenuService;
import manage.modules.worker.model.WorkerInfo;

import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Result;

@RequiredLogin
public class IndexAction extends BaseAction implements CurrentWorkerAware {

	private static final long serialVersionUID = 7559909780462776781L;
	private WorkerInfo currentWorker;
	private MenuService menuService;

	@Override
	@Action(value = "index", results = { @Result(name = SUCCESS, location = Constants.INDEX_PAGE) })
	public String execute() throws Exception {
		request.setAttribute("menuFolders",
				menuService.listMenusByWorkerId(currentWorker.getWorkerId()));
		return SUCCESS;
	}

	public void setMenuService(MenuService menuService) {
		this.menuService = menuService;
	}

	@Override
	public void setCurrentWorker(WorkerInfo currentWorker) {
		this.currentWorker = currentWorker;
	}

}
